﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace calculator_windowsForms
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (number1.Text != "" && number2.Text != ""&&op.Text!="")
            {
                double a = Double.Parse(number1.Text);
                double b = Double.Parse(number2.Text);
                string s = op.Text;
                switch (s)
                {
                    case "+": result.Text = (a + b).ToString(); break;
                    case "-": result.Text = (a - b).ToString(); break;
                    case "*": result.Text = (a * b).ToString(); break;
                    case "/":
                        {
                            if (b != 0)
                            {
                                result.Text = (a / b).ToString(); 
                            }
                            else
                            {
                                result.Text = "wrong";
                            }
                            break;
                        }
                    case "%":
                        {
                            if (b != 0)
                            {
                                result.Text = (a % b).ToString();
                            }
                            else
                            {
                                result.Text = "wrong";
                            }
                            break;
                        }
                    default: result.Text = "wrong"; break;
                }
            }
            else
            {
                result.Text = "wrong";
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
    }
}
